cmake_minimum_required(VERSION 3.10)
project(vulkan-compute)

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_BUILD_TYPE Debug)


ADD_DEFINITIONS(-DUSE_VULKAN=1)
ADD_DEFINITIONS(-DUSE_CUDA=0)

ADD_DEFINITIONS(-DALLOW_PARTIAL_FORWARD=1)

IF (WIN32)
    # include directories
    SET(INCLUDE_DIRS
        "${PROJECT_SOURCE_DIR}/src"
        "D:/Libs/protobuf-3.11.4/include"
        "$ENV{VULKAN_SDK}/Include"
        "${PROJECT_SOURCE_DIR}/vendor/stbimage/include"
    )

    # link 
    SET(LIBRARIES_DEBUG 
        "D:/Libs/protobuf-3.11.4/lib/Debug/libprotobuf.lib"
        "$ENV{VULKAN_SDK}/Lib/vulkan-1.lib"
        "$ENV{VULKAN_SDK}/Lib/glslangd.lib"
        "$ENV{VULKAN_SDK}/Lib/HLSLd.lib"
        "$ENV{VULKAN_SDK}/Lib/SPIRVd.lib"
        "$ENV{VULKAN_SDK}/Lib/OGLCompilerd.lib"
        "$ENV{VULKAN_SDK}/Lib/OSDependentd.lib"
        "$ENV{VULKAN_SDK}/Lib/SPVRemapperd.lib"
    )
    SET(LIBRARIES_RELEASE
        "D:/Libs/protobuf-3.11.4/lib/Release/libprotobuf.lib"
        "$ENV{VULKAN_SDK}/Lib/vulkan-1.lib"
        "$ENV{VULKAN_SDK}/Lib/glslang.lib"
        "$ENV{VULKAN_SDK}/Lib/HLSL.lib"
        "$ENV{VULKAN_SDK}/Lib/SPIRV.lib"
        "$ENV{VULKAN_SDK}/Lib/OGLCompiler.lib"
        "$ENV{VULKAN_SDK}/Lib/OSDependent.lib"
        "$ENV{VULKAN_SDK}/Lib/SPVRemapper.lib"
    )

    SET(ONNX_NAMESPACE "onnx")
    ADD_DEFINITIONS(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
    if(MSVC)
        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
        set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
    endif()
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATIONS)

ELSE ()
    # Linux
ENDIF (WIN32)

configure_file(
    "${PROJECT_SOURCE_DIR}/src/vkinfer/core/root_dir.h.in"
    "${PROJECT_SOURCE_DIR}/src/vkinfer/core/root_dir.h"
)

FILE(GLOB_RECURSE SOURCE_CPP_FILES 
    "${PROJECT_SOURCE_DIR}/src/*.c"
    "${PROJECT_SOURCE_DIR}/src/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/*.cc"
    )
FILE(GLOB_RECURSE HEADER_FILES 
    "${PROJECT_SOURCE_DIR}/src/*.h"
    "${PROJECT_SOURCE_DIR}/src/*.hpp")

ADD_EXECUTABLE(
    vk_compute
    ${SOURCE_CPP_FILES} 
    ${HEADER_FILES}
)

TARGET_INCLUDE_DIRECTORIES(
    vk_compute PRIVATE
    ${INCLUDE_DIRS}
)

TARGET_LINK_LIBRARIES(
    vk_compute PUBLIC
    $<$<CONFIG:Debug>:${LIBRARIES_DEBUG}>
    $<$<CONFIG:Release>:${LIBRARIES_RELEASE}>
)
